package com.chenbei.controller.admin.common;

import com.chenbei.common.domain.vo.ApiResponse;
import com.chenbei.common.domain.vo.UploadFileResult;
import com.chenbei.common.service.IFileUploadService;
import com.chenbei.common.util.ApiResponseUtil;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/admin/common/file")
public class FileController {

    @Autowired
    private IFileUploadService fileUploadService;

    @Operation(summary = "文件上传")
    @PostMapping("upload")
    public ApiResponse<UploadFileResult> upload(MultipartFile file) {
        UploadFileResult upload = fileUploadService.upload(file);
        return ApiResponseUtil.success(upload);
    }
}
